package es.battleship.model;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import com.google.appengine.api.datastore.Key;

@XmlRootElement
@PersistenceCapable
public class PlayerPair {
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)	
    private Key id;
	
	@Persistent	
	private String user1;
	
	@Persistent	
	private String user2;
	
	@Persistent
	private Board board1;
	
	@Persistent
	private Board board2;
	
	@Persistent(defaultFetchGroup = "true")
	private Game game;

	public PlayerPair() {
		super();
	}
	
	@XmlJavaTypeAdapter(KeyAdapter.class)
	public Key getId() {
		return id;
	}

	public void setId(Key id) {
		this.id = id;
	}
	
	@XmlTransient
	public Board getBoard1() {
		return board1;
	}

	public void setBoard1(Board board1) {
		this.board1 = board1;
	}

	@XmlTransient
	public Board getBoard2() {
		return board2;
	}

	public void setBoard2(Board board2) {
		this.board2 = board2;
	}

	public String getUser1() {
		return user1;
	}

	public void setUser1(String user1) {
		this.user1 = user1;
	}

	public String getUser2() {
		return user2;
	}

	public void setUser2(String user2) {
		this.user2 = user2;
	}

	public Game getGame() {
		return game;
	}

	public void setGame(Game game) {
		this.game = game;
	}


	public String toString() {
		return "PlayerPair { Id: " 
				+ id 
				+ " player1: " 
				+  board1 
				+ " player2: " 
				+  board2 
				+ " }";
	}
}
